﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using FindIt.DAL;
using MySql.Data;
using MySql.Data.MySqlClient;
using System.Drawing;

namespace FindIt.UI.Pages
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void btnLogin_Click(object sender, EventArgs e)
        {


            string username = txtUN.Text;
            string password = txtPass.Text;

            UserDB db = new UserDB();
            if (db.LoginUser(username, password))
            {
                FindIt.BLL.User.RoleType role = FindIt.BLL.User.GetRoleByUsername(username);

                Session["username"] = username;
                Session["role"] = role.ToString();
                Response.Redirect("Default.aspx");
            }

            else
            {
                lblMessage.ForeColor = Color.Red;
                lblMessage.Text = "Login Failed!";
            }
        }
    }
}
